<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.hzqy.commons.utils.ConstantUtils" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>模板列表</title>
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/defalut.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/public.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/ddspstyle.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/icon.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/WdatePicker/skin/WdatePicker.css"> 
<script type="text/javascript" src="../../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../../static/js/jquery.easyui.min.js"></script>
<script type="text/javascript"	src="../../static/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../static/js/jquery.validate.js"></script>
<script type="text/javascript" src="../../static/js/index.js"></script>
<script type="text/javascript" src="../../static/js/WdatePicker/WdatePicker.js"></script>
<script type="text/javascript" charset="utf-8" src="../../ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="../../ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../../ueditor/lang/zh-cn/zh-cn.js"></script>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<%
	String f_vc_customid = request.getParameter("f_vc_customid");//客户id
	String []nonceObj=ConstantUtils.getNonceObject();
%>
<script type="text/javascript">
	document.onkeydown = function(event) {
		var e = event || window.event || arguments.callee.caller.arguments[0];
		if (e && e.keyCode == 13) { // enter 键
			try {
				searchData();
			} catch (e) {
				gotoSearch($('#easyui-treegrid'));
			}
		}
	};
</script>
<style type="text/css">
.imgsw {
	background: url(../resource/images/a0133.png) no-repeat;
	height: 14px;
	width: 17px;
	display: inline-block;
	border: 0;
}
.OperateTitle
{
	font-size:16px;
    height: 36px;
    background: url(images/labelbg.gif);
}
.td_class
{
    color: #434343;
    font-family:  Verdana, Arial, Helvetica, sans-serif;
}
.xbuton2 {
    background-image: url(images/bt_bg2.jpg);
    border: 1px solid #085890;
    line-height: 20px;
    height: 20px;
    padding: 2px 5px 0 5px;
    text-decoration: none;
    color: #fff;
    cursor: pointer;
}
</style>
<script type="text/javascript">
		var queryParams;
		function EasyuiDatagrid(){
			$("#easyui-datagrid").datagrid({
				url: '../../virtual_channel/template_list.do',
				nowrap: true,
				striped: true,
				border: false,
				fit: true,
				rownumbers:true,
				queryParams: getGueryParams(),
				columns: [[
					{field:'id',checkbox:true},
					{field:'f_vct_id',title:'ID',align:'center',width:50},
					{field:'f_vct_name',title:'名称',align:'center',width:150},
					{field:'f_vct_cdate',title:'创建日期',align:'center',width:150,		
						formatter:function(value,row,index){
							if(value){
								return new Date(value).Format("yyyy-MM-dd hh:mm:ss");
							}else {
								return '';
							}
						}},
					{field:'f_vct_udate',title:'最后修改日期',align:'center',width:150,		
						formatter:function(value,row,index){
							if(value){
								return new Date(value).Format("yyyy-MM-dd hh:mm:ss");
							}else {
								return '';
							}
						}},
					{field:'f_vct_desc',title:'说明',align:'center',width:200},
					{field:'_parentId',title:'操作',align:'center',width:250,
						formatter:function(value,row,index){
							str= '<a id="modify" class="easyui-linkbutton l-btn l-btn-plain" plain="true" iconcls="icon-edit" href="javascript:void(0);" onclick="modify(\''+row.f_vct_id+'\');"><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">修改</span></span></a>';
							str+= '<a id="remove" class="easyui-linkbutton l-btn l-btn-plain" plain="true" iconcls="icon-edit" href="javascript:void(0);" onclick="remove(\''+row.f_vct_id+'\');"><span class="l-btn-left"><span class="l-btn-text icon-remove l-btn-icon-left">删除</span></span></a>';
							str+= '<a id="progremManage" class="easyui-linkbutton l-btn l-btn-plain" plain="true" iconcls="icon-edit" href="javascript:void(0);" onclick="progremManage(\''+row.f_vct_channelid+'\');"><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">节目管理</span></span></a>';
							str+= '<a id="putToPlay" class="easyui-linkbutton l-btn l-btn-plain" plain="true" iconcls="icon-edit" href="javascript:void(0);" onclick="putToPlay(\''+row.f_vct_channelid+'\');"><span class="l-btn-left"><span class="l-btn-text icon-ok l-btn-icon-left">投放</span></span></a>';
							return str;
				    	}
					}
				]],
				singleSelect:true,
				pagination: true,
		//		view: detailview,
				pageList: [10,20,30,40,50],
				pageSize:10,
				toolbar: '#toolbar',
			//	detailFormatter:function(index,row){
		//			return '<div class="ddv" style="padding:5px 0">111111</div>';
			//	},
				onExpandRow: function(index,row){
				
				},
				onSelect: function(rowIndex,rowData) {
					
				},
				onUnselect: function(rowIndex,rowData) {
					
				},
				onCheckAll: function(rowIndex,rowData) {
					
				},
				onUncheckAll: function(rowIndex,rowData) {
				
				},
				onLoadSuccess: function (data) {
					if(data.total==-1) {
						$.messager.defaults={ok:"确定",cancel:"取消"};
						$.messager.confirm('提示', '用户尚未登录,请登录', function(r){
							if (r){
							    window.parent.location.href='/cbweb';
							    return false;
							}
						});
					}
				}
			});
	    }
		
		function endOfSubmit(){
			closeDialog($("#dialogMoveBusiness"));
			closeDialog($("#dialogMenuEdit"));
			gotoSearch();
		}
		function getGueryParams(){
			return {
				f_vct_customid : '<%=f_vc_customid%>'
			};
		}
		$(function(){
			new EasyuiDatagrid();
			gotoSearch = function(){
				$("#easyui-datagrid").datagrid('reload',getGueryParams());
			};
		});
		function SubgridTabOnSelect(title,index){
			setTimeout(function(){
				$("#easyui-datagrid").datagrid('fixDetailRowHeight',index);
			},300);
			setTimeout(function(){
				$("#easyui-datagrid").datagrid('fixDetailRowHeight',index);
			},3000);
	    }
	 
		
		function load(){
			$(".datagrid-row-expander datagrid-row-expand").attr("display","none"); 
			 $(".datebox :text").attr("readonly","readonly");
		}
		
		function _resert(){
			$("#areacode").val("");
			$("#projectname").val("");
			$("#status").val("");
			$("#beginTime").datebox('setValue','');
			$("#endTime").datebox('setValue','');
		}
		
		function onpress(){
		var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异
   		  	if (event.keyCode == 13){  
      			gotoSearch($('#easyui-treegrid'));
    		}
		}
		
	
		function info(obj,obj2){
			var row = obj;
			var type = obj2;
			if(obj2=="null"){
				type = 0;
			}
			openDialog($("#dlg"),'workorder_info.jsp?f_wo_id='+row+'&f_wo_type='+type);
		}
		function edit(f_wo_id,f_wo_type){
			var row = f_wo_id;
			var type = f_wo_type;
			if(f_wo_type=="null"){
				type = 1;
			}
			openDialog($("#dlg"),'workorder_update.jsp?f_wo_id='+row+'&f_wo_type='+type);
		}
		function review(id,type) {
			openDialog($('#dlg'),'workorder_rev.jsp?f_wo_id='+id+'&f_wo_type='+type); 
		}
		
		/* 节目模板增加页 */
		function add(){
			document.forms[0].action = "vchannel_program_template_add.jsp?preform=selforadd&f_vc_customid=<%=f_vc_customid%>";
			document.forms[0].submit();
		}
		function closePage(){
			document.forms[0].action= "vchannel_programs.jsp";
			document.forms[0].submit();
		}
		function modify(f_vct_id){
			document.forms[0].action = "vchannel_program_template_update.jsp?preform=sel&f_vct_id="+f_vct_id;
			document.forms[0].submit();
		}
		
		/* function remove(f_vct_id){
			alert(f_vct_id);
			if(confirm("确定要删除此模版吗？")){
				document.forms[0].action = "../../virtual_channel/delete_template.do?f_vct_id="+f_vct_id;
				document.forms[0].submit();
			}
		} */
		function remove(f_vct_id){
			$.messager.confirm('确认删除记录','确认删除信息么？',function(r) {
					if (r) {
						$.ajax({
							type : "POST",
							url : "../../virtual_channel/delete_template.do?f_vct_id="+f_vct_id+"&stime=<%=nonceObj[0]%>&sign=<%=nonceObj[1]%>",
							dataType : "json",
							success : function(result) {
								if (result.success == true) {
									alert( "删除成功!");
									if (checkAjaxRequestValidity(result)) {
										gotoSearch($('#easyui-treegrid'));
									}
								} else {
									alert("删除失败!");
								}
								window.location.reload();
							},
							error : function(result) {
								alert("删除异常，请联系管理员");
								if ($.isFunction(window.showMessager)) {
									window.showMessager(result.resultTitle,result.result);
								}
							}
						});
					}
			});
		}
		function progremManage(_f_vct_channelid){
			document.forms[0].action = "vchannel_program_edit.jsp?insertOrUpdate=update&f_vc_id="+_f_vct_channelid+"&f_vc_parentid="+_f_vct_channelid;
			document.forms[0].submit();
		}
		
		function putToPlay(_f_vct_channelid){
			$.messager.confirm('确定是否投放','确定要投放么?',function(r){
				if(r){
					app_ajax('../../virtual_channel/update_effect_status.do?f_vc_parentid='+_f_vct_channelid+'&f_vc_customid=<%=f_vc_customid%>&stime=<%=nonceObj[0]%>&sign=<%=nonceObj[1]%>',
					'',
					function(msg){
						if(msg.success) {
							alert("操作成功!");
							if (checkAjaxRequestValidity(msg)) {
								gotoSearch($('#easyui-treegrid'));
							}
						} else {
							alert("操作异常，请联系管理员");
							if($.isFunction(window.showMessager)){
								window.showMessager(msg.resultTitle,msg.result);
							}
						}
						window.location.reload();
					}
					);
				}
			});
		}
	</script>
  </head>
  <body >
	<!-- <table width="100%" cellspacing="0" cellpadding="3"  class="tablex">
				<tr>
					<td height="25" valign="middle" align="center" class="OperateTitle td_class" colspan="6">播放列表模版</td>
				</tr>
	</table> -->	
	<table id="easyui-datagrid"  title="播放列表模版" ></table>		
	<div id="toolbar" class="easyui_datagrid_toolbar" style="">
		<div class="easyuiSearch">
			<form onsubmit="return false;" method="post">
				<input type="hidden" name="f_vct_id">
				<input type="hidden" name="layoutModelId">
				<input type="hidden" name="f_vct_channelid" value="">
				
				<table cellspacing="0" cellpadding="0" width="90%">
					<tr>
						<td colspan="4" align="right">
						    <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-add', plain:true" onclick="add()">增  加</a> 
							<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-cancel', plain:true" onclick="closePage()">关 闭</a>
						</td>
					</tr> 
				</table>
			</form>
		</div>
	</div>
	<div id="dlg" class="easyui-dialog" style="width: 900px; height: 700px; padding-top: 0px;"
		data-options="title: '工单详情', iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
		<iframe scrolling="auto" frameborder="0" style="width: 100%; height: 99%;"></iframe>
	</div>
	</body>
</html>